export default class Item extends Sprite {
  
  constructor() {
    super();
  }

  init(type) {

    this.type = type;

    if(!this.icon) {
      this.starTexture = Laya.loader.getRes("res/item_1.png");
      this.speedTexture = Laya.loader.getRes("res/item_3.png");
      this.flyTexture = Laya.loader.getRes("res/item_4.png");
      this.icon = new Sprite();
      this.addChild(this.icon);
    }

    this.icon.graphics.clear();

    switch (type) {
      case Item.ITEM_TYPE_STAR:
        this.icon.graphics.drawTexture(this.starTexture, 0, 0, 32, 32);break;
      case Item.ITEM_TYPE_SPEED:
        this.icon.graphics.drawTexture(this.speedTexture, 0, 0, 40, 53);break;
      case Item.ITEM_TYPE_FLY:
        this.icon.graphics.drawTexture(this.flyTexture, 0, 0, 40, 48);break;
      default: ;
    }
  }
}

// 类型分类
// 星星
Item.ITEM_TYPE_STAR = "item_type_star";
// 加速
Item.ITEM_TYPE_SPEED = "item_type_speed";
// 悬空
Item.ITEM_TYPE_FLY = "item_type_fly";